#include <bits/stdc++.h>

using namespace std;
class Solution {
   public:
    int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {
        int ret = 0;
        sort(horizontalCuts.begin(), horizontalCuts.end());
        sort(verticalCuts.begin(), verticalCuts.end());
        auto f = [](vector<int>& v, int border) -> int {
            int pre = 0, ret = 0;
            for (auto & e : v){
                ret = max(e - pre, ret);
                pre = e;
            }
            return max(ret, border - pre);
        };
        return (long long)f(horizontalCuts, h) * f(verticalCuts, w) % (int)(1e9 + 7);
    }
};